---
page_title: "cloudflare_email_routing_rule Resource - Cloudflare"
subcategory: ""
description: |-
  The Email Routing Rule https://developers.cloudflare.com/email-routing/setup/email-routing-addresses/#email-rule-actions resource allows you to create and manage email routing rules for a zone.
---

# cloudflare_email_routing_rule (Resource)

The [Email Routing Rule](https://developers.cloudflare.com/email-routing/setup/email-routing-addresses/#email-rule-actions) resource allows you to create and manage email routing rules for a zone.

## Example Usage

```terraform
resource "cloudflare_email_routing_rule" "main" {
  zone_id = "0da42c8d2132a9ddaf714f9e7c920711"
  name    = "terraform rule"
  enabled = true

  matcher {
    type  = "literal"
    field = "to"
    value = "test@example.com"
  }

  action {
    type  = "forward"
    value = ["destinationaddress@example.net"]
  }
}
```
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Routing rule name.
- `zone_id` (String) The zone identifier to target for the resource.

### Optional

- `action` (Block Set) Actions to take when a match is found. (see [below for nested schema](#nestedblock--action))
- `enabled` (Boolean) Whether the email routing rule is enabled.
- `matcher` (Block Set) Matching patterns to forward to your actions. (see [below for nested schema](#nestedblock--matcher))
- `priority` (Number) The priority of the email routing rule.

### Read-Only

- `id` (String) The ID of the email routing rule.
- `tag` (String) The tag of the email routing rule.

<a id="nestedblock--action"></a>
### Nested Schema for `action`

Required:

- `type` (String) Type of action. Available values: `forward`, `worker`, `drop`

Optional:

- `value` (Set of String) Value to match on. Required for `type` of `literal`.


<a id="nestedblock--matcher"></a>
### Nested Schema for `matcher`

Required:

- `type` (String) Type of matcher. Available values: `literal`, `all`

Optional:

- `field` (String) Field to match on. Required for `type` of `literal`.
- `value` (String) Value to match on. Required for `type` of `literal`.

## Import

Import is supported using the following syntax:

```shell
$ terraform import cloudflare_email_routing_rule.example <zone_id>/<email_routing_rule_id>
```
